<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <my-hello></my-hello>
        <hr>

        <my-world></my-world>
    </div>

    <template id="content">
        <div>
            <h3>msg:{{msg}}</h3>
            <input type="text" v-model="msg">
        </div>
    </template>
</body>
<script>
    /**
     * 方式1：Vue.component(组件名, 组件构造器)
     */ 
    var MyComponent = Vue.extend({
        template:'#content',
        data(){
            return {
                msg:'welcome'
            }
        }
    })
    // Vue.component('hello',MyComponent)
    // Vue.component('my-hello',MyComponent)
    Vue.component('MyHello',MyComponent)

    /**
     * 方式2：Vue.component(组件名, 选项对象)
     */
    Vue.component('my-world',{
        template:'#content',
        data(){
            return {
                msg:'欢迎'
            }
        }
    })

    // 根组件
    new Vue({
        el:'#app'
    })
</script>
</html>